package ui.model;

import bean.DataFrameContainer;
import bean.ModelType;
import io.reactivex.Observable;
import io.reactivex.ObservableEmitter;
import io.reactivex.ObservableOnSubscribe;
import io.reactivex.functions.Consumer;
import joinery.DataFrame;
import org.jfree.ui.tabbedui.VerticalLayout;
import tool.DataProvider;
import tool.Lg;
import tool.UIEventSender;
import ui.listener.HTableEvent;
import ui.listener.TableClickAction;
import ui.listener.TableClickAdapter;
import ui.view.BaseFilterView;
import ui.view.HScrollTableView;
import ui.view.LabelTextPanel;

import javax.swing.*;
import java.awt.*;
import java.awt.event.KeyEvent;
import java.awt.event.MouseEvent;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

import static tool.TableProperty.*;

public class StudentListModel extends BaseFilterView {
    private JTextPane sidPanel = new JTextPane();
    private JTextPane namePanel = new JTextPane();

    private Map<String,JTextPane> textPaneMap = new LinkedHashMap<String, JTextPane>()
    {
        {
            put(SID, sidPanel);
            put(NAME,namePanel);
        }
    };
    private TableClickAction tableAction;

    public StudentListModel() {
        super(ModelType.StudentList);
        /**
         * 顶部是筛选框
         * 底部是表格
         * 拥有判断是否跟选课连接的方法
         */
        tableAction = new TableClickAction() {
            @Override
            public void actionPerformed(MouseEvent mouseEvent, HTableEvent e) {
                if (mouseEvent.getClickCount() == 2)
                {
                    List<String> row = e.getRow();
                    UIEventSender.getInstance().ChooseSidCall(row);
                }
            }
        };
        iniFilterPanel(textPaneMap);
        iniConsume(ID);

        iniTable(DataProvider.provideStudentId(),ID);
        iniTabelAction(tableAction);
    }

}
